﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Connection对象 : System.Web.UI.Page
{
    private string 東江;
    protected string 数据库语句;
    protected void Page_Load(object sender, EventArgs e)
    {
        東江 = ConfigurationSettings.AppSettings["SqlConn"];
        数据库语句 = "select count(*) from zhuanti";
        SqlConnection SqlConn = new SqlConnection(東江);
        SqlCommand SqlCom = new SqlCommand(数据库语句, SqlConn);
        SqlConn.Open();
        int result = (int)SqlCom.ExecuteScalar();
        Response.Write("总共记录:"+result.ToString());
        //显示Connection 对象的属性;
        Response.Write("<br>SQL Server 数据的状态:"+SqlConn.State.ToString() );
        Response.Write("<br>SQL Server 数据库连接的通讯包大小:" + SqlConn.PacketSize.ToString());
        Response.Write("<br>SQL Server 数据库的数据库名:" + SqlConn.Database.ToString());
        Response.Write("<br>SQL Server 数据库的工作站名:" + SqlConn.WorkstationId.ToString());
        SqlConn.Close();
        Response.Write("<br>SQL Server 数据的状态:" + SqlConn.State.ToString());
        
    }
}
